package dao;

import org.apache.ibatis.annotations.*;
import pojo.Jjbqd;

import java.util.List;

@Mapper
public interface JjbqdMapper {

    // 新增急救包清单
    @Insert("INSERT INTO jjbqd (item_name, description, is_essential) " +
            "VALUES (#{itemName}, #{description}, #{isEssential})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int add(Jjbqd jjbqd);

    // 查询所有急救包清单
    @Select("SELECT * FROM jjbqd")
    List<Jjbqd> findAll();

    // 根据ID查询
    @Select("SELECT * FROM jjbqd WHERE id = #{id}")
    Jjbqd findById(Integer id);

    // 更新急救包清单
    @Update("UPDATE jjbqd " +
            "SET item_name = #{itemName}, " +
            "description = #{description}, " +
            "is_essential = #{isEssential} " +
            "WHERE id = #{id}")
    int update(Jjbqd jjbqd);

    // 删除急救包清单
    @Delete("DELETE FROM jjbqd WHERE id = #{id}")
    int deleteById(Integer id);
}